package com.example.admin.config;

import com.example.admin.interceptor.TokenIntercepeor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author 王同学
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Autowired
    TokenIntercepeor tokenIntercepeor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
         //注册拦截器            //拦截器名字，跟上面的对应
        registry.addInterceptor(tokenIntercepeor)
                //要拦截的路径
                .addPathPatterns("/**")
                //放行哪个路径， 因为方法那边判断放行find 所以这边写find系列就多此一举
                //可以在后面追加放行
                .excludePathPatterns("/**/add/**")
                .excludePathPatterns("/**/update/**");
                //相当于三个方法
    }
}
